//
// Created by rengen.gong on 2021/12/2.
//

#ifndef LEARN1_CLOCK_H
#define LEARN1_CLOCK_H

#include "iostream"

using namespace std;

class Clock {

private:
    int hour;
    int minute;
    int second;

    friend class ClockFriend;

public:
    Clock(int h = 0, int m = 0, int s = 0) {
        hour = h;
        minute = m;
        second = s;
    }

    void operator++();

    void operator()(int h, int m, int s);

    void showTime() {
        cout << "current time="
             << hour << ":"
             << minute << ":"
             << second
             << endl;
    }


};

void Clock::operator++() {

    ++second;
    if (second == 60) {
        second = 0;
        ++minute;
        if (minute == 60) {
            minute = 0;
            hour++;
            if (hour == 24) {
                hour = 0;
            }
        }
    }

}

void Clock::operator()(int h, int m, int s) {

    hour = h;
    minute = m;
    second = s;

}

#endif //LEARN1_CLOCK_H
